package com.icehand.payment.config;

import com.icehand.common.constants.RabbitmqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author icehand
 */
@Configuration
public class RabbitMQConfiguration {
    private static final String NOTIFY_EXCHANGE = "notifyExchange";

    @Bean
    public Queue orderQueue() {
        return new Queue(RabbitmqConstants.ORDER_QUEUE);
    }

    @Bean
    TopicExchange notifyExchange() {
        return new TopicExchange(NOTIFY_EXCHANGE);
    }

    @Bean
    Binding topicBind(TopicExchange notifyExchange) {
        return BindingBuilder.bind(orderQueue()).to(notifyExchange).with("order-notify-.#");
    }
}
